<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/v2/console/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>十方天资官网后台管理系统</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="${path}/v2/console/css/base.css">
<link rel="stylesheet" href="${path}/v2/console/css/style.css">
<script src="${path}/v2/console/js/jquery-1.9.1.min.js"></script>
</head>
<body>
	<div id="wrapper">
		<div class="main">
			<div class="main-right">
				<div class="column-name">
					<h2>
						信息管理 > <b>新建</b>
					</h2>
				</div>
				<div class="form">
				<form id="staticinfoform" name="staticinfoform" action="${pageContext.request.contextPath}/siteStaticinfo/addSiteStaticinfo.html" method="post">
					<input type="hidden" name="type" value="${type}">
					<div class="form-item">
						<div class="form-name">名称:</div>
						<div class="form-input">
							<input type="text" id="" name="name" class="input" value="">
							<div class="clearfix"></div>
							<div class="form-error red"></div>
						</div>
					</div>
					<div class="form-item">
						<div class="form-name">链接地址:</div>
						<div class="form-input">
							<input type="text" id="" name="url" class="input" value="">
							<div class="clearfix"></div>
							<div class="form-error red"></div>
						</div>
					</div>
					<div class="form-item">
						<div class="form-name">排序号:</div>
						<div class="form-input">
							<input type="text" id="" name="ord" class="input" value="">
							<div class="clearfix"></div>
							<div class="form-error red"></div>
						</div>
					</div>
					<input type="hidden" name="pic" id="pic">
				</form>
				<form id="firstPicForm" onsubmit="return false;">
						<div class="form-item form-item01">
							<div class="form-name">图片:</div>
							<div class="form-input">
								<input type='text' id='textfield' class='input' /> 
								<input type="file" name="img" class="file input" id="fileField"  onchange="document.getElementById('textfield').value=this.value" />
    							<button class="btn-blue" onclick="uploadFirstImage()">上传图片</button>
    							<div class="clearfix"></div>
    							<div id="firstPic" class="form-img hide">
    								<img src="${path}/v2/console/images/back.jpg" alt="">
    							</div>
							</div>
						</div>
					</form>
					<button type="button" class="btn w144" onclick="add()">保  存</button>
				</div>
				
			</div>
		</div>
	</div>
	<script>
	function add(){
		$("#staticinfoform").submit();
	}
	
	function uploadFirstImage(){
		var formData = new FormData($("#firstPicForm")[0]);
		$.ajax({
			type : "post",
			url : "uploadFirstImage.html",
			dataType : "json",
			data : formData,
			async : false,
			cache: false,
	        contentType: false,
	        processData: false,
			success : function(data) {
				if(data.ajax_status == "ajax_status_success"){
					$("#firstPic").find("img").attr("src",data.targetPath);
					$("#pic").val(data.picUrl);
					$("#firstPic").show();
				}else{
					alert(data.msg);
				}
				return false;
			},
			error : function(XMLHttpRequest, textStatus, errorThrown){
	          alert("出错了！");
	       }
		});
		return false;;
	}
	
	</script>
</body>
</html>